﻿using DAL;
using FubiManger.Controls;
using Model;
using Smobiler.Core;
using Smobiler.Core.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace FubiManger.UI
{
    partial class DisksForm : Smobiler.Core.Controls.MobileForm
    {
        public DisksForm() : base()
        {
            //This call is required by the SmobilerForm.
            InitializeComponent();
        }
        /// <summary>
        /// 商户ID
        /// </summary>
        public string merchantid { get; set; }
        /// <summary>
        /// 餐桌集合
        /// </summary>
        List<ms_disk> disklist = new List<ms_disk>();
        /// <summary>
        /// 桌号名称
        /// </summary>
        public string diskname { get; set; }
        /// <summary>
        /// 用户ID
        /// </summary>
        public string adminid { get; set; }
        private void panclose_Press(object sender, EventArgs e)
        {
            this.Close();
        }

        private void DisksForm_Load(object sender, EventArgs e)
        {
            
            Refsh();
        }

        /// <summary>
        /// 刷新
        /// </summary>
        public void Refsh()
        {
            //if (pandisk.Controls.Count > 0)
            //    pandisk.Controls.Clear();
            disklist = diskDal.Querybymerid(merchantid);
            // pandisk.Height = disklist.Count * 48;
            //pandisks.Height = pandisk.Height + 64;
            //for (int i = 0; i < disklist.Count; i++)
            //{
            //    diskfoodcontrol con = new diskfoodcontrol();
            //    con.diskname = disklist[i].ds_disknmae;
            //    con.diskperson = disklist[i].ds_person;
            //    con.diskid = disklist[i].ds_id;//编号
            //    con.merchantid = merchantid;//商户号
            //    pandisk.Controls.Add(con);
            //}
            DataTable table = new DataTable();
            table.Columns.Add("diskname");
            table.Columns.Add("person");
            table.Columns.Add("merchantid");
            table.Columns.Add("adminid");
            for (int i = 0; i < disklist.Count; i++)
            {
                table.Rows.Add(disklist[i].ds_disknmae, disklist[i].ds_person,merchantid,adminid);
            }
            lvdisk.DataSource = table;
            lvdisk.DataBind();
        }
        public void Showfrm(string diskname)
        {
            DisksForm frm = new DisksForm();
            frm.merchantid = "2";
            frm.diskname = diskname;
            this.Form.Show(frm, true);
        }
        private void button1_Press(object sender, EventArgs e)
        {
            this.Form.Show(new OrderfoodForm(), true);
        }
    }
}